Use case: ICACHE remap region successful

This use case shows how to configure and enable a remapping region using ICACHE, comparing HAL1 and HAL2.

Sequence diagram

    @startuml
    "User\nApplication"->"ICACHE\nDriver": HAL_ICACHE_Disable
    "ICACHE\nDriver"-->"User\nApplication":HAL_OK
    "User\nApplication"->"ICACHE\nDriver": HAL_ICACHE_ConfigAssociativityMode
    "ICACHE\nDriver"-->"User\nApplication":HAL_OK
    note left: return\nstatus
    "User\nApplication"->"ICACHE\nDriver": HAL_ICACHE_EnableRemapRegion
    "ICACHE\nDriver"-->"User\nApplication":HAL_OK
    note left: return\nstatus
    "User\nApplication"->"ICACHE\nDriver": HAL_ICACHE_Enable
    "ICACHE\nDriver"-->"User\nApplication":HAL_OK
    note left: return\nstatus
    @enduml

Code snippet

HAL1

HAL2

HAL_ICACHE_Disable();

HAL_ICACHE_ConfigAssociativityMode(ICACHE_1WAY);

/* Remap SRAM memory */
region_config.TrafficRoute    = ICACHE_MASTER2_PORT;
region_config.OutputBurstType = ICACHE_OUTPUT_BURST_INCR;
region_config.Size            = ICACHE_REGIONSIZE_2MB;
region_config.BaseAddress     = 0x10000000;
region_config.RemapAddress    = 0x60000000;

/* Enable the remapped region */
if (HAL_ICACHE_EnableRemapRegion(ICACHE_REGION_1, &region_config) != HAL_OK)
{
  Error_Handler();
}

/* Enable the Instruction and Data Cache */
HAL_ICACHE_Enable();
HAL_ICACHE_Init(&hicache1, HAL_ICACHE1);

HAL_ICACHE_SetAssociativityMode(&hicache1, HAL_ICACHE_ASSOCIATIVITY_1WAY);

/* Remap SRAM memory */
region_config.master_port   = HAL_ICACHE_MASTER2_PORT;
region_config.output_burst  = HAL_ICACHE_BURST_INCR;
region_config.size          = HAL_ICACHE_REGION_SIZE_2MBYTES;
region_config.base_address  = 0x10000000;
region_config.remap_address = 0x60000000;

/* Configure the remapped region */
if (HAL_ICACHE_SetConfigRemapRegion(&hicache1, HAL_ICACHE_REGION_1, &region_config) != HAL_OK)
{
  Error_Handler();
}

if (HAL_ICACHE_EnableRemapRegion(&hicache1, HAL_ICACHE_REGION_1) != HAL_OK)
{
  Error_Handler();
}

/* Start the Instruction Cache */
HAL_ICACHE_Start(&hicache1, HAL_ICACHE_IT_NONE);

Key changes

  1. HAL2 introduces an explicit configuration step for remap regions (HAL_ICACHE_SetConfigRemapRegion()), separate from enabling the region.

  2. HAL2 uses a handle-based flow (HAL_ICACHE_Init() + HAL_ICACHE_Start()), whereas HAL1 uses global enable/disable APIs.

  3. Several enums/fields are renamed in HAL2 (for example, region size and master port names).